class Solution {
public:
    int numSub(string s) {
        int zero = -1;
        int ans = 0;
        int mod = 1e9 + 7;
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == '0') zero = i;
            else ans = (ans + i - zero) % mod;
        }
        return ans;
    }
};